package com.zsrt.devbase.common.exception;
/**
 * session中的personCode不存在异常
 * @author leixin
 * @Date 2017年4月26日
 * @version 1.0
 */
public class PersonCodeSessionException extends Exception {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int id; 								// a unique id
	private String classname; 						// the name of the class
	private String method; 							// the name of the method
	private String message; 						// a detailed message
	private PersonCodeSessionException previous = null; // the exception which was caught
	private String separator = "/n"; 					// line separator
	
	
	public PersonCodeSessionException() {
	}
	
	public PersonCodeSessionException(int id) {
		this.id = id;
	}

	public PersonCodeSessionException(int id, String classname) {
		this(id);
		this.id = id;
	}

	public PersonCodeSessionException(int id, String classname, String method) {
		this(id,classname);
		this.id = id;
	}

	public PersonCodeSessionException(int id, String classname, String method, String message) {
		this(id,classname,method);
		this.id = id;
	}
	

	public PersonCodeSessionException(int id, String classname, String method, String message,
			PersonCodeSessionException previous) {
		this(id, classname, method, message);
		this.previous = previous;
	}

	public String traceBack() {
		return traceBack("/n");
	}

	public String traceBack(String sep) {
		this.separator = sep;
		int level = 0;
		PersonCodeSessionException e = this;
		String text = line("Calling sequence (top to bottom)");
		while (e != null) {
			level++;
			text += line("--level " + level + "--------------------------------------");
			text += line("Class/Method: " + e.classname + "/" + e.method);
			text += line("Id          : " + e.id);
			text += line("Message     : " + e.message);
			e = e.previous;
		}
		return text;
	}

	private String line(String s) {
		return s + separator;
	}

}
